<!doctype html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  <link rel="stylesheet" href="../../static/BOSGeo/BOSGeo.css" />
  <title>添加组合实体</title>
  <style>
    html {
      font-size: 12px;
    }

    html,
    body,
    #mapContainer {
      height: 100%;
      width: 100%;
      padding: 0;
      margin: 0;
    }

  </style>
</head>

<body>
  <div id="mapContainer"></div>
  <script src="../../static/BOSGeo/BOSGeo.js"></script>
  <script>
    var map = new BOSGeo.Map('mapContainer', {
    mapType: BOSGeo.TDT_IMAGERY
    });

    map.flyTo(121.4724, 31.16552, 5000)

    var layers = map.layers;
    var entityCollection = new BOSGeo.LayerCollection({
        name: '实体集合',
        type: 'entity'
    });

    layers.add(entityCollection);
    let combineEntity = new BOSGeo.EntityCombineLayer({
    name: '组合实体',
    data: [
        {
            type: 'line',
            position: [121.4724, 31.16552, 0, 121.47419, 31.16681, 0, 121.47656, 31.1658, 0, 121.47868, 31.16778, 0],
            color: '#7970f9',
            width: 10,
        },
        {
            type: 'polygon',
            position: [121.47326, 31.16421, -0, 121.47703, 31.16524, 0, 121.47698, 31.16357, 0, 121.4749, 31.16291, 0],
            color: '#7970f9',
            height: 5,
        },
        {
            type: 'rect',
            position: [121.4744, 31.16279, 0, 121.47775, 31.16221, 0],
            color: '#7970f9',
            height: 30,
        },
        {
            type: 'ellipse',
            position: [121.47826, 31.16447, 0],
            color: '#7970f9',
            radius: 50,
            height: 20,
        }
    ],
    onClick: layer => {
        layer.zoomTo();
    }
    });
    entityCollection.add(combineEntity)
    // combineEntity.setVisible(true); // 显示组合实体
    // combineEntity.setVisible(true); // 隐藏组合实体
  </script>
</body>

</html>